import {
	_serviceTypeDict,
	_shopTypeDict
} from '@/config/dict.js'
export default {
	serviceTypeDict(value) {
		//服务单下单-服务类型
		return value ? _serviceTypeDict[value] || "" : "";
	},
	orderDutyTimeFilter(row) {
		if (row.serviceSystem == "YX") {
			return row.dutyTime || "";
		} else {
			if (row.dutyTime1 === null || row.dutyTime1 == '') {
				return "";
			} else {
				if (row.dutyTime2 === null || row.dutyTime2 == '') {
					return row.dutyTime1;
				} else {
					return `${row.dutyTime1}${
	            row.dutyTime2 == "0"
	              ? "上午"
	              : row.dutyTime2 == "1"
	              ? "下午"
	              : row.dutyTime2 == "2"
	              ? "晚上"
	              : ""
	          }`;
				}
			}
		}
	},
	// 处理状态
	appointOrderStatusFilter(value) {
		if (value === null) {
			return "";
		}
		let obj = {
			0: "未处理",
			1: "处理中",
			2: "已完成"
		};
		return obj[value];
	},
	// 审核状态
	updateHrGongdanAppointSubmit(value){
		if(value===null){
			return "";
		}
		let obj={
			0:"未审核",
			1:"审核中",
			2:"已审核"
		};
		return obj[value];
	},
	dateFormateYMD(value) {
		let date = new Date(value.replace(/\-/g, '/'))
		return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`
	},
	nickNameFilter(value) {
		let encodedString = String.fromCodePoint.apply(null, new Uint8Array(value));
		let decodedString = decodeURIComponent(escape(encodedString)); //没有这一步中文会乱码
		return decodedString;
		// const textDecoder = new TextDecoder();
		// const encodedText = Uint8Array.of(...value);
		// const decodedText = textDecoder.decode(encodedText);
		// return decodedText
	},
	shopTypeFilter(value) {
		if(value === null) return ''
		return _shopTypeDict[value] ? _shopTypeDict[value] : ''
	}
}
